﻿@model Zatify.WebUI.Models.BillingTransactionHistoryViewModel
@{
    ViewBag.Title = "Billing";
    ViewBag.ContentTitle = "Billing";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";
}
@section Styles
{
    <style type="text/css">
        .inner_container
        {
            float: none;
        }
    </style>
}
<div class="business_interface_area">
    <div class="business_profile_categories">
        <div class="label_text current_account_balance">
            @if (@Model.BillingTransactionHistoryList.Count > 0)
            {
                if (Model.PromotionId == null)
                {
                <text> <strong>Current Account Balance:</strong>
                @if (@Model.BillingTransactionHistoryList.Count > 0)
                {
                    <text>@Model.BillingTransactionHistoryList[0].CurrentAccoutnBalance.ToString("$0.00")</text>
                }
                </text>
                }
                else
                {
                <text>
                @if (@Model.BillingTransactionHistoryList.Count > 0)
                {
                    <strong>Promotion @Model.BillingTransactionHistoryList[0].Description:</strong>
                    @Model.BillingTransactionHistoryList[0].PromotionName
                }
                else
                {
                <strong>Promotion</strong>
                }
                </text>
                }
            }
        </div>
        <div class="label_text current_account_balance transaction_history_tt">
            Transaction History</div>
        <table cellspacing="0" cellpadding="0" border="0" class="billing_tabel">
            <tbody>
                <tr>
                    <th>
                        Date
                    </th>
                    <th>
                        Type
                    </th>
                    <th>
                        Description
                    </th>
                    <th>
                        Debit
                    </th>
                    <th>
                        Credit
                    </th>
                    <th class="z_balance">
                        Balance
                    </th>
                </tr>
                @for (int i = 0; i < Model.BillingTransactionHistoryList.Count; i++)
                {
                    <tr class="@((i % 2 == 0) ? "billing_row1" : "billing_row2")">
                        <td>
                            <a href="@Url.Action("TransactionHistory", "Billing", new
                            {
                                dateOperation = Model.BillingTransactionHistoryList[i].Date.ToShortDateString()
                            })">
                                @Model.BillingTransactionHistoryList[i].Date.ToString("MM/dd/yyyy")
                            </a>
                        </td>
                        <td>
                            @Model.BillingTransactionHistoryList[i].Type
                        </td>
                        <td>
                        @if (@Model.BillingTransactionHistoryList[i].PromotionId > 0)
                        {
                            <a href="@Url.Action("PromotionTransactionHistory", new { promotionId = @Model.BillingTransactionHistoryList[i].PromotionId })">
                                @Model.BillingTransactionHistoryList[i].Description
                            </a>
                        }
                        else
                        {
                             @Model.BillingTransactionHistoryList[i].Description
                        }
                        </td>
                        <td>
                        @if (@Model.BillingTransactionHistoryList[i].PromotionId > 0)
                        {
                            <a href="@Url.Action("PromotionTransactionHistory", "Billing", new
                                {
                                    promotionId = Model.BillingTransactionHistoryList[i].PromotionId,
                                    //date = Model.BillingTransactionHistoryList[i].Date.ToString("MM/dd/yyyy")
                                })">
                                @if (Model.BillingTransactionHistoryList[i].Debit > 0)
                                {
                                    <text>$@Model.BillingTransactionHistoryList[i].Debit.ToString("0.00")</text>
                                }
                            </a>
                        }
                        else
                        {
                             if (Model.BillingTransactionHistoryList[i].Debit > 0)
                             {
                                    <text>$@Model.BillingTransactionHistoryList[i].Debit.ToString("0.00")</text>
                             }
                        }
                        </td>
                        <td>
                        @if (@Model.BillingTransactionHistoryList[i].PromotionId > 0)
                        {
                            <a href="@Url.Action("PromotionTransactionHistory", "Billing", new
                                {
                                    promotionId = Model.BillingTransactionHistoryList[i].PromotionId,
                                    //date = Model.BillingTransactionHistoryList[i].Date.ToString("MM/dd/yyyy")
                                })">
                                @if (Model.BillingTransactionHistoryList[i].Credit > 0)
                                {
                                    <text>$@Model.BillingTransactionHistoryList[i].Credit.ToString("0.00")</text>
                                }
                            </a>
                        }
                        else
                        {
                             if (Model.BillingTransactionHistoryList[i].Credit > 0)
                             {
                                    <text>$@Model.BillingTransactionHistoryList[i].Credit.ToString("0.00")</text>
                             }
                        }
                        </td>
                        <td class="z_balance">
                        @if (@Model.BillingTransactionHistoryList[i].PromotionId > 0)
                        {
                            <a href="@Url.Action("PromotionTransactionHistory", "Billing", new
                                {
                                    //transactionId = Model.BillingTransactionHistoryList[i].TransactionId 
                                    promotionId = Model.BillingTransactionHistoryList[i].PromotionId
                                })">
                                $@Model.BillingTransactionHistoryList[i].Balance.ToString("0.00")
                            </a>
                        }
                        else
                        {
                             <text>$@Model.BillingTransactionHistoryList[i].Balance.ToString("0.00")</text>
                        }
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        <div class="billing_control">
            @if (Model.PagingInfo.CurrentPage > 1)
            {
                <a class="gold_btn" href="@(Model.PagingInfo.CurrentPage == 1 ? "#" : Url.Action("TransactionHistory", new { promotionId = Model.PromotionId, page = (Model.PagingInfo.CurrentPage - 1) }))" style="float: left;">
                    Prev</a>
            }
            @if (Model.PagingInfo.CurrentPage < Model.PagingInfo.TotalPages)
            {
                <a class="gold_btn" href="@(Model.PagingInfo.CurrentPage == Model.PagingInfo.TotalPages ? "#" : Url.Action("TransactionHistory", new { promotionId = Model.PromotionId, page = (Model.PagingInfo.CurrentPage + 1) }))" style="float: right;">
                    Next</a>
            }
        </div>
    </div>
    <div class="clearfix">
    </div>
</div>
